package ooad.nextgen.domain;

public class Money {
	private float amount;
	private String currency;
	public Money(){
		this.currency = "RMB";
		this.amount = 0.00F;
	}
	public Money(float amount){
		this.currency = "RMB";
		this.amount = amount;
	}
	public Money(float amount, String currency) {
		super();
		this.amount = amount;
		this.currency = currency;
	}
	public float getAmount() {
		return amount;
	}
	public void setAmount(float amount) {
		this.amount = amount;
	}
	public String getCurrency() {
		return currency;
	}
	public void setCurrency(String currency) {
		this.currency = currency;
	}
	public Money times(int quantity){
		float temp = (float) (this.getAmount()*quantity);
		this.setAmount(temp);
		return this;		
	}
	public Money discount(float percentage){
		float temp = (float) (this.getAmount()*percentage);
		this.setAmount(temp);
		return this;		
	} 
	public Money add(Money subtotal){
		float temp = (float) (this.getAmount()+subtotal.getAmount());
		this.setAmount(temp);
		return this;		
	}
	public Money minus(Money total){
		float temp = (float) (this.getAmount()-total.getAmount());
		this.setAmount(temp);
		return this;		
	}
	public boolean equals(Money money){
		boolean flag = false;
		if (this.amount == money.getAmount())
			flag = true;
		return flag;			
	}
	public boolean less(Money money){
		boolean flag = false;
		if(this.getAmount() < money.getAmount()){
			flag = true;
		}
		return flag;
	}
	public Money min(Money money) {
		if (this.getAmount()<money.getAmount())
			return this;
		else
			return money;
	}
}
